package com.leetcode;

import java.util.Scanner;

public class MP3光标位置 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            // 歌曲的数目
            int musicCount = Integer.parseInt(scanner.nextLine());
            //执行的命令
            String order = scanner.nextLine();
            String s;
            int count = Math.min(musicCount, 4);
            int current = 1, start = 1, end = 4;
            char[] chars = order.toCharArray();
            for (char aChar : chars) {
                if (aChar == 'U') {
                    if (current == 1) {
                        current = musicCount;
                        start = musicCount - (count - 1);
                        end = musicCount;
                    } else {
                        current--;
                        if (current < start) {
                            end -= 1;
                            start -= 1;
                        }
                    }
                } else if (aChar == 'D') {
                    if (current == musicCount) {
                        current = 1;
                        start = 1;
                        end = count;
                    } else {
                        current++;
                        if (current > end) {
                            end += 1;
                            start += 1;
                        }
                    }
                }
            }

            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < count; i++) {
                builder.append(start).append(" ");
                start += 1;
            }
            System.out.println(builder.deleteCharAt(builder.lastIndexOf(" ")));
            System.out.println(current);
        }
    }
}
